package com.dkm.orproject.dkmoa.service.serviceimpl;

import com.dkm.orproject.dkmoa.dao.OaOfficeSuppliesTypeMapper;
import com.dkm.orproject.dkmoa.domain.OaOfficeSuppliesType;
import com.dkm.orproject.dkmoa.service.OaOfficeSuppliesTypeService;
import com.dkm.orproject.utils.utils.IdToobtainUtils;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 *  @ClassName : OaOfficeSuppliesTypeServiceImpl  //类名
 *  @Description : 办公用品类型  //描述
 *  @Author : 石智诚  //作者
 *  @Date: 2020-11-12 11:26  //时间
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OaOfficeSuppliesTypeServiceImpl implements OaOfficeSuppliesTypeService {
    /**
     * 办公用品类型
     */
    @Resource
    OaOfficeSuppliesTypeMapper suppliesTypeMapper;
    /**
     * 雪花类型
     */
    @Resource
    IdToobtainUtils utils;
    /**
     * 根据id删除
     * @param pkOfficeSuppliesTypeId 办公用品类型id
     * @return 回调函数
     */
    @Override
    public int deleteByTypeId(Long pkOfficeSuppliesTypeId) {
        return suppliesTypeMapper.deleteByPrimaryKey(pkOfficeSuppliesTypeId);
    }

    /**
     * 增加
     * @param record 办公用品类型
     * @return 回调函数
     */
    @Override
    public int insert(OaOfficeSuppliesType record) {
        record.setPkOfficeSuppliesTypeId(utils.getNumberId());
        record.setIsRevision("1");
        return suppliesTypeMapper.insertSelective(record);
    }

    /**
     * 根据id查询
     * @param pkOfficeSuppliesTypeId 办公用品类型id
     * @return 回调函数
     */
    @Override
    public OaOfficeSuppliesType selectByTypeId(Long pkOfficeSuppliesTypeId) {
        return suppliesTypeMapper.selectByPrimaryKey(pkOfficeSuppliesTypeId);
    }

    /**
     * 根据id更新
     * @param record 办公用品类型
     * @return 回调函数
     */
    @Override
    public int updateByTypeId(OaOfficeSuppliesType record) {
        return suppliesTypeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<OaOfficeSuppliesType> selectAll(OaOfficeSuppliesType suppliesType, String startDate, String endDate, Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        return suppliesTypeMapper.selectAll(suppliesType,startDate,endDate);
    }

    @Override
    public Long rowCount(OaOfficeSuppliesType suppliesType, String startDate, String endDate) {
        return suppliesTypeMapper.rowCount(suppliesType,startDate,endDate);
    }

    @Override
    public List<OaOfficeSuppliesType> findAll(List<Long> ids) {
        return suppliesTypeMapper.findAll(ids);
    }

    @Override
    public int deleteAll(List<Long> ids) {
        return suppliesTypeMapper.deleteAll(ids);
    }

    @Override
    public List<OaOfficeSuppliesType> selectType(Long id ) {
        return suppliesTypeMapper.selectType(id);
    }
}
